﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Abs_classes_data;
using System_States_Signals;

namespace Conc_classes_data
{
    public class pump_controller : abs_controller
    {
        public pump_controller(tank controlled_object, Double normal_value)
            : base(controlled_object, normal_value)
        {
        }

        protected override void Create_Sensor(abs_controlled_object obj)
        {
            pump_sensor sens = new pump_sensor((tank)obj);
            this._sensor = sens;
        }

        public override System_States_Signals.Value_State Check_statement()
        {
            Value_State s;

            if (abs_sensor.Not_Initialized == this._sensor.Value)
            {
                s = Value_State.Not_Initialized;
            }

            if (this._sensor.Value < 50 || this._sensor.Value > 500)
            {
                s = Value_State.Crash;
            }
            else
            {
                if (this._sensor.Value > this._normal_value - 50 && this._sensor.Value < this._normal_value + 50)
                {
                    s = Value_State.Normal;
                }
                else
                {
                    s = Value_State.Check;
                }
            }
            
            return s;
        }

        public override void Do_Work(double value)
        {
            ((tank)Object).Get_Gas(value);
        }

        public override void Do_Crash()
        {
            ((tank)Object).Pressure = 600;
        }
    }
}
